﻿
using ServerBase.Config;

namespace SvGame.Controller;

public partial class GameHandler
{
    /// <summary>
    /// 看玩家
    /// </summary>
    /// <param name="pack"></param>
    public int C2GLookPlayer(MyPackage pack)
    {
        pack.GetMsg(out C2GLookPlayer req);
        var rsp = new G2CLookPlayer();

        if (!pack.PackGetPlayer(out var player) || player is null)
        {
            return 0;
        }
        if (!player.Room.DictPlayer.TryGetValue(req.Puid, out var tp))
        {
            return player.MessageError("没有这个玩家");
        }

        // 被观察者
        tp.Message($"{player.Name}正盯着你看，不知道打些什么主意。");

        var sb = new StringBuilder();
        if (!tp.Title.IsNullOrEmpty())
        {
            sb.AppendLine($"「{tp.Title}」{tp.Name}");
        }
        else
        {
            sb.AppendLine($"「普通百姓」{tp.Name}");
        }
        var pro = GenderPronoun((EGender)tp.Gender);
        if (tp.Age < 10)
        {
            sb.AppendLine($"{pro}看起来显然还不到十岁。");
        }
        else
        {
            sb.AppendLine($"{pro}看起来约{ChineseNumber(tp.Age / 10 * 10)}多岁。");
        }
        var objlevel = Exp2Level(tp.Exp);
        if (objlevel > player.Level * 3)
        {
            sb.Append($"{pro}的修为看起来似乎#HIW#无法估量#NOR#。");
            sb.AppendLine($"{pro}出手似乎很重。");
        }
        else
        {
            sb.Append($"{pro}的修为看起来{DescLevel(objlevel)}。");
            sb.AppendLine($"{pro}出手似乎不重。");
            //sb.AppendLine($"{pro}出手似乎{DescDamage(ppp.Dt.cdamage)}。");
        }
        var descper = DescPer(tp.Age, (EGender)tp.Gender, tp.Talent.Per);
        sb.AppendLine($"{pro}{descper}");
        sb.Append($"{pro}{DescKee(tp.StatusCur.Kee, tp.StatusMax.Kee)}");
        //rsp.Desc = sb.ToString();
        player.Message(sb.ToString());

        return pack.Send(rsp);
    }
    /// <summary>
    /// 聊天
    /// </summary>
    /// <param name="pack"></param>
    public int C2GChatSend(MyPackage pack)
    {
        pack.GetMsg(out C2GChatSend req);
        var rsp = new G2CChatSend();

        if (!pack.PackGetPlayer(out var player) || player is null)
        {
            return 0;
        }
        if (req.Text.Length > 100)
        {
            return pack.Send(rsp, EProtocolResult.文本太长);
        }
        player.Chat(req);

        return pack.Send(rsp);
    }
}
